<template>
	<view class="swiper-details">
		<!-- <view class="title">{{ content.titleName }}</view> -->
		<view v-html="content.originalContent" class="content-edit"></view>
		<view class="header-tips">参与方式</view>
		<view class="tips" v-html="content.tipsContent"></view>
		<view class="header-tips">请在下方留言</view>
		<view class="text-area"><big-text :maxLength="300" v-model="textSave" :height="300" placeholder="请输入信息"></big-text></view>
		<button @click="saveHandle">提交</button>
		<popup-active :visible.sync="showHonor" :popScreenList="popScreenList" @toPage="toPage" @close="back"></popup-active>
	</view>
</template>

<script>
import http from '../../common/request.js';
import popupActive from '@/components/popup-activity/popup-activity.vue';
import BigText from '@/components/big-text/index.vue';
import { getCommonShareInfo } from '@/common/utils.js';
export default {
	onShareAppMessage() {
		return getCommonShareInfo();
	},
	onLoad: function(option) {
		this.id = option.recruitPartnerId;
		this.detail();
	},
	components: {
		popupActive,
		BigText
	},
	data() {
		return {
			dataList: {},
			textSave: '',
			id: '',
			content: '',
			showHonor: false,
			popScreenList: []
		};
	},
	methods: {
		toPage(value) {
			http('/api/duiba/getNoLoginUrl?credits=0&redirect=' + value, { method: 'GET' }).then(result => {
				if (result.code == 200) {
					// #ifdef H5
					location.href = result.data;
					// #endif
					// #ifdef MP-WEIXIN
					uni.navigateTo({
						url: '../../home/web_view?url=' + encodeURIComponent(result.data),
						animationType: 'pop-in',
						animationDuration: 200
					});
					//#endif
				}
			});
		},
		detail() {
			http('/api/sysRecruitPartner/' + this.id, {
				method: 'GET',
				data: {}
			}).then(result => {
				this.content = result.data || {};
			});
		},
		saveHandle(option) {
			if (!this.textSave) {
				uni.showToast({
					title: '请输入留言',
					icon: 'none',
					duration: 2000
				});
				return;
			}
			http('/api/cusRecruitPartnerMessage', {
				method: 'POST',
				data: {
					recruitPartnerId: this.id,
					messageDetail: this.textSave
				}
			}).then(result => {
				const list = result.popScreen || [];
				if (result.code == 200) {
					uni.showToast({
						title: '留言成功',
						icon: 'none',
						duration: 1000
					});
					setTimeout(() => {
						if (list.length > 0) {
							this.showHonor = true;
							this.popScreenList = list;
						} else {
							this.back();
						}
					}, 1000);
				}
			});
		},
		back() {
			uni.navigateBack({
				delta: 1,
				animationType: 'pop-out',
				animationDuration: 200
			});
		}
	}
};
</script>

<style lang="less" scoped>
.swiper-details {
	text-align: center;
	padding-bottom: 32rpx;
	.title {
		font-size: 50rpx;
		text-align: center;
		color: #66645d;
		padding: 20rpx 0;
	}
	.content-edit {
		// text-align: center;
		// color: #66645d;
		// p {
		// 	padding: 10rpx 0;
		// }
		margin-bottom: 36rpx;
	}
	.header-tips {
		display: inline-block;
		width: 264rpx;
		height: 82rpx;
		background: rgba(250, 204, 107, 0.5);
		font-size: 30rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #66645d;
		line-height: 82rpx;
		text-align: center;
		position: relative;
		&::before,
		&::after {
			content: '';
			position: absolute;
			height: 1rpx;
			transform: scaleY(0.5) translateY(-50%);
			width: 152rpx;
			top: 50%;
			background-color: rgba(151, 151, 151, 0.5);
		}
		&::before {
			left: -176rpx;
		}
		&::after {
			right: -176rpx;
		}
	}
	.tips {
		margin: 36rpx 68rpx 100rpx 68rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #66645d;
		line-height: 40rpx;
	}

	.text-area {
		text-align: left;
		border-radius: 12rpx;
		margin: 36rpx 40rpx;
		padding: 23rpx 27rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #66645d;
		line-height: 40rpx;
		background-color: #ffffff;
		width: calc(100% - 80rpx);
	}

	button {
		margin: 0 30rpx;
		font-size: 30rpx;
		font-weight: 400;
		color: #66645d;
		background: #facc6b;
		border-radius: 12rpx;
	}
}
</style>
